package com.punai.customer.service.impl;

import java.util.List;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.punai.common.core.domain.TreeBo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.punai.customer.mapper.CusSubpkChapterMapper;
import com.punai.customer.domain.CusSubpkChapter;
import com.punai.customer.service.ICusSubpkChapterService;

/**
 * 工序费用项章节Service业务层处理
 *
 * @author zxw
 * @date 2022-12-04
 */
@Service
public class CusSubpkChapterServiceImpl extends ServiceImpl<CusSubpkChapterMapper,CusSubpkChapter> implements ICusSubpkChapterService
{
    @Autowired
    private CusSubpkChapterMapper cusSubpkChapterMapper;

    /**
     * 查询工序费用项章节
     *
     * @param id 工序费用项章节主键
     * @return 工序费用项章节
     */
    @Override
    public CusSubpkChapter selectCusSubpkChapterById(String id)
    {
        return cusSubpkChapterMapper.selectCusSubpkChapterById(id);
    }

    /**
     * 查询工序费用项章节列表
     *
     * @param cusSubpkChapter 工序费用项章节
     * @return 工序费用项章节
     */
    @Override
    public List<CusSubpkChapter> selectCusSubpkChapterList(CusSubpkChapter cusSubpkChapter)
    {
        return cusSubpkChapterMapper.selectCusSubpkChapterList(cusSubpkChapter);
    }

    /**
     * 新增工序费用项章节
     *
     * @param cusSubpkChapter 工序费用项章节
     * @return 结果
     */
    @Override
    public int insertCusSubpkChapter(CusSubpkChapter cusSubpkChapter)
    {
            return cusSubpkChapterMapper.insert(cusSubpkChapter);
    }

    /**
     * 修改工序费用项章节
     *
     * @param cusSubpkChapter 工序费用项章节
     * @return 结果
     */
    @Override
    public int updateCusSubpkChapter(CusSubpkChapter cusSubpkChapter)
    {
        return cusSubpkChapterMapper.updateById(cusSubpkChapter);
    }

    /**
     * 批量删除工序费用项章节
     *
     * @param ids 需要删除的工序费用项章节主键
     * @return 结果
     */
    @Override
    public int deleteCusSubpkChapterByIds(String[] ids)
    {
        return cusSubpkChapterMapper.deleteCusSubpkChapterByIds(ids);
    }

    /**
     * 删除工序费用项章节信息
     *
     * @param id 工序费用项章节主键
     * @return 结果
     */
    @Override
    public int deleteCusSubpkChapterById(String id)
    {
        return cusSubpkChapterMapper.deleteCusSubpkChapterById(id);
    }

    @Override
    public List<TreeBo> treeData(Long companyId) {
        LambdaQueryWrapper<CusSubpkChapter> queryWrapper = Wrappers.lambdaQuery();
        queryWrapper.eq(CusSubpkChapter::getCompanyId,companyId);
        List<CusSubpkChapter> cusSubpkChapters = cusSubpkChapterMapper.selectList(queryWrapper);
        return TreeBo.convert(cusSubpkChapters);
    }
}
